package com.wn.manpower.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.Hr;
import com.wn.manpower.mapper.HumanResourcesMapper;
import com.wn.manpower.service.HumanResourcesService;
import com.wn.utils.PageBeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 人力资源表
 * @author dzj
 * date: 2022/10/20
 */
@Slf4j
@Service
public class HumanResourcesServiceImp implements HumanResourcesService {

    @Autowired
    private HumanResourcesMapper humanResourcesMapper;

    @Override
    public void add(Hr hr) {
        humanResourcesMapper.add(hr);
    }

    @Override
    public void update(Hr hr) {
        humanResourcesMapper.update(hr);
    }

    @Override
    public Hr getById(int id) {
        return humanResourcesMapper.getById(id);
    }

    @Override
    public PageBean<Hr> getPageByCondition(Hr hr, int currPage, int pageSize) {
        Page<Object> page = PageHelper.startPage(currPage, pageSize);
        List<Hr> humanResourcesList = humanResourcesMapper.getByCondition(hr);
        PageBean<Hr> pageBean = PageBeanUtil.getPageBean(humanResourcesList, page, currPage, pageSize);
        return pageBean;
    }

}
